package com.zeekr.myapplication3

import android.os.SystemClock
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

class MyTest {
    suspend fun MyTest.await(): String = suspendCoroutine { continuation ->
        abc(object : MyCall {
            override fun onCall(text: String) {
                super.onCall(text)
                continuation.resume("sadfafasdfsfsd")
            }
        })
    }

    suspend fun myCall(): String = suspendCoroutine { continuation ->
        abc(object : MyCall {
            override fun onCall(text: String) {
                super.onCall(text)
                continuation.resume("dfasfdasfasdfasd")
            }
        })
    }

    private fun abc(call: MyCall) {
        Thread {
            SystemClock.sleep(3000)
            call.onCall("hello123")
        }.start()
    }

    suspend fun newMyTest(): MyTest {
        withContext(Dispatchers.IO) {

        }
        return MyTest()
    }
}